<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/validate.jsp"%>
<%@ include file="/common/code.jsp"%>
<%@ include file="/common/user.jsp"%>
<%
	Message validateTokenMsg = Token.validateToken(input); 
	Map code = new HashMap();
	if (validateTokenMsg.getErrcode() == 0) {
		Token token = (Token)validateTokenMsg.get("token");
		Integer uid = token.getUid();
		User user = userByUid(uid);
		Integer type = user.getType();
		String userType = type.equals(USER_EMPLOYEE)?"doctor":"patient";
		code.put("code", encodeQrCode(uid, userType));
	}
	Integer doctorId = input.getInt("doctor_id", -1);
	if (doctorId != -1)
		code.put("code", encodeQrCode(doctorId, "doctor"));
    msg.put("data", code);
    Tools.encryptPrint(out, msg);
%>
